package com.sofun.ai.controller;

import dev.langchain4j.web.search.WebSearchEngine;
import dev.langchain4j.web.search.WebSearchOrganicResult;
import dev.langchain4j.web.search.WebSearchResults;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController()
@RequestMapping("/retrieval")
public class RetrievalController {

    @Resource
    WebSearchEngine searXNGWebSearchEnginel;

    @RequestMapping(value = "/search")
    public List<WebSearchOrganicResult> search(@RequestParam(defaultValue="我叫张佳伟") String message) {
        WebSearchResults search = searXNGWebSearchEnginel.search(message);
        List<WebSearchOrganicResult> results = search.results();
        return results;
    }
}
